/**
 * 系统升级控制器
 */
package com.mvc.controller.upgrade;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mvc.controller.base.BaseController;
import com.mvc.model.upgrade.SoftwareUpgrade;
import com.mvc.service.upgrade.SoftwareUpgradeServiceI;

/**
 * 系统升级控制器
 * 
 * @author qingjie
 * @version 1.0 Date:2016-01-12
 */
@Controller
@RequestMapping("/softwartUpgrade")
public class SoftwareUpgradeController extends BaseController{

	@Autowired
	private SoftwareUpgradeServiceI susi;

	/**
	 * 获取最新的更新记录信息
	 * 
	 * @author qingjie
	 * @return Date:2016-01-12
	 */
	@RequestMapping("/forAndroid")
	@ResponseBody
	public SoftwareUpgrade getNewSoftwareUpgradeForAndroid(HttpServletRequest request,
			HttpServletResponse response) {
		 return susi.getNewSoftwareUpgradeForAndroid();

	}
	
	/**
	 * 获取android升级的url
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/forAndroidUrl")
	public String getNewSoftwareUpgradeForAndroidUrl(HttpServletRequest request,
			HttpServletResponse response) {
		 request.setAttribute("url", susi.getNewSoftwareUpgradeForAndroid().getUrl());
		 return "/web/upgrade/result";

	}

	/**
	 * 根据条件获取升级信息 说明：根据传递参数进行查询 现在开放：id 等查询参数 ordrBy 为排序参数如 ordrBy =
	 * "order by id desc"
	 * 
	 * @param su
	 * @return
	 */
	@RequestMapping("/findSoftwareUpgrade")
	@ResponseBody
	public List<SoftwareUpgrade> findSoftwareUpgrade(SoftwareUpgrade su) {
		return susi.findNewSoftwareUpgrade(su);
	}


}
